import React, { useEffect, useState } from 'react'
import { Select, Form } from 'antd'
import EventHub from '../EventHub/index.jsx'
const { Option } = Select
const { Item: FormItem } = Form

export function ESelect({ params }) {
  const { formType, value, data=[], label, index, children, onChange, ...other } = params || {}
  const [ESelectValue, setESelectValue] = useState(value)

  useEffect(() => {
    console.log(params, index, "----------  Select  -------------");
  }, [params.value])



  let SelectType = Select;

  return <FormItem {...{label}}>
    <SelectType
      onChange={(value) => {
        setESelectValue(value)
        params.value = value
      }}
      value={ESelectValue}
      {...other}
    >

      {data.map((item) => {
        return <Option key={item.value}>{item.text}</Option>
      })}
    </SelectType>
  </FormItem>

}